package com.mf.model;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import org.hibernate.annotations.Type;

@Entity
@Table(name = "ORDDCM_MF_ESL")
// , uniqueConstraints = { @UniqueConstraint(columnNames = { "FROM_ID", "TO_ID" }) })
public class Eslesme {
	private int id;
	private Kullanici from;
	private Kullanici to;
	private Date tarih;
	private boolean flag;

	// FIXME: AUTO düzenlenecek
	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	@Column(name = "ID")
	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	@ManyToOne(fetch = FetchType.EAGER)
	@JoinColumn(name = "FROM_ID", nullable = false)
	public Kullanici getFrom() {
		return from;
	}

	public void setFrom(Kullanici from) {
		this.from = from;
	}

	@ManyToOne(fetch = FetchType.EAGER)
	@JoinColumn(name = "TO_ID", nullable = false)
	public Kullanici getTo() {
		return to;
	}

	public void setTo(Kullanici to) {
		this.to = to;
	}

	@Column(name = "TARIH", nullable = false)
	public final Date getTarih() {
		return tarih;
	}

	public final void setTarih(Date tarih) {
		this.tarih = tarih;
	}

	@Column(name = "FLAG", nullable = false)
	@Type(type = "org.hibernate.type.BooleanType")
	public boolean isFlag() {
		return flag;
	}

	public void setFlag(boolean flag) {
		this.flag = flag;
	}

}
